package AcceptanceTests;


import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class SearchAcceptanceTest {
	
	private Bridge br;


	@Before
	public void setUp() throws Exception {
		this.br = new Bridge();
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testSearchUseCase(){
		this.br.register("searcher", "1234");
		this.br.login("searcher", "1234");
		this.br.addPost("msg1","Test message number one.");
		this.br.addPost("msg2","Test message number two.");
		String result = br.searchByAuthor("searcher", 0, 10); 
		assertTrue(result.contains("msg1") & result.contains("msg2"));
		result = br.searchByAuthor("falseAuthor", 0, 10);
		assertNull(result);
		result = br.searchByContent("one", 0, 10);
		assertTrue(result.contains("msg1"));
		result = br.searchByContent("one AND two", 0, 10);
		assertTrue(result.equals("0\n"));
		result = br.searchByContent("one OR two", 0, 10);
		assertTrue(result.contains("msg1") & result.contains("msg2"));
	}
}
